﻿@model IEnumerable<HanGu.Entity.MemberInfo>
@{
    Layout = null;
    int i = 1;
    ViewBag.ViewTitle = "客户基本信息";
    var SearchParma = ViewData["SearchParma"] as HanGu.Entity.UniversallySearchParam;
    var MemberGrade = ViewData["MemberGrade"] as SelectList;
    var Degree = ViewData["Degree"] as SelectList;
    var SexList = ViewData["SexList"] as SelectList;
    string lookup = Request["lookup"];
    string formCallback = "navTabSearch(this)";
    if (!string.IsNullOrEmpty(lookup))
    {
        formCallback = "dwzSearch(this, 'dialog')";
    }
    var selectedID = TempData["SelectedMember"] as List<int> ?? new List<int>();
    TempData["SelectedMember"] = selectedID;
    var SelectedMembers = new List<HanGu.Entity.MemberInfo>();
    var SelectingMembers = new List<HanGu.Entity.MemberInfo>();
    SelectedMembers = Model.Where(c => selectedID.Contains(c.ID)).ToList();
    SelectingMembers = Model.Where(c => !selectedID.Contains(c.ID)).ToList();
    
}
<script>
    function selectedCheckBox(obj) {
        var checkbox = $(obj).find(':checkbox');
        var isChecked = checkbox.attr("CHECKED") == "checked";
        checkbox.attr("checked", !isChecked);
    }
    
  
</script>
<div class="pageHeader">
    <form id="pagerForm" method="get" action="/CustomerInfo/Default/index?action=page&OpID=@ViewData["OperateID"]">
    <input type="hidden" name="pageNum" value="1" />
    <input type="hidden" name="numPerPage" value="@ViewData["pageSize"]" />
    <input type="hidden" name="RowCount" value="@ViewData["RowCount"]" />
    <input type="hidden" name="orderField" value="${param.orderField}" />
    <input type="hidden" name="Title" value="@SearchParma.Ttile" />
    <input type="hidden" name="Suitabler" value="@SearchParma.Suitabler" />
    <input type="hidden" name="Lectcher" value="@SearchParma.Lectcher" />
    <input type="hidden" name="PalayAdress" value="@SearchParma.PalayAdress" />
    <input type="hidden" name="Degree" value="@SearchParma.Degree" />
    <input type="hidden" name="StarTime" value="@SearchParma.StarDateTime" />
    <input type="hidden" name="EndTime" value="@SearchParma.EndDateTime" />
    <input type="hidden" name="lookup" value="@lookup" />
    <input type="hidden" name="IsBacklist" value="@SearchParma.IsBacklist" />
    <input type="hidden" name="Sex" value="@SearchParma.Sex" />
    <input type="hidden" name="Tel" value="@SearchParma.Tel" />
    <input type="hidden" name="NativePlace" value="@SearchParma.NativePlace" />
    <input type="hidden" name="IsMarry" value="@SearchParma.IsMarry" />
    <input type="hidden" name="HasChildren" value="@SearchParma.HasChildren" />
    <input type="hidden" name="Provice" value="@SearchParma.Provice" />
    <input type="hidden" name="City" value="@SearchParma.City" />
    <input type="hidden" name="Oganization" value="@SearchParma.Oganization" />
    <input type="hidden" name="ChargeRandS" value="@SearchParma.ChargeRandS" />
    <input type="hidden" name="ChargeRandE" value="@SearchParma.ChargeRandE" />
    <input type="hidden" name="ContractRandS" value="@SearchParma.ContractRandS" />
    <input type="hidden" name="ContractRandE" value="@SearchParma.ContractRandE" />
    <input type="hidden" name="ContractNumRandS" value="@SearchParma.ContractNumRandS" />
    <input type="hidden" name="ContractNumRandE" value="@SearchParma.ContractNumRandE" />
    <input type="hidden" name="ImportantLevel" value="@SearchParma.ImportantLevel" />
    <input type="hidden" name="AssignedIn" value="@SearchParma.AssignedIn" />
    <input type="hidden" name="Groups" value="@SearchParma.Groups" />
    <input type="hidden" name="IsPage" value="@SearchParma.IsPage" />
    </form>
    <div id="SelectorHighSearch">
        @Html.Action("HighSeach", "Default", new { area = "CustomerInfo" })
    </div>
</div>
<div class="pageContent">
    <div class="tabs" currentindex="0" eventtype="chick" >
        <div class="tabsHeader">
            <div class="tabsHeaderContent">
                <ul>
                    <li><a><span>已选择会员</span></a></li>
                    <li><a><span>未选择会员</span></a></li>
                </ul>
            </div>
        </div>
        <div class="tabsContent">
            <div id="SelectedMember">
                <table class="table" width="100%">
                    <thead>
                        <tr class="header">
                            <th>
                                序号
                            </th>
                            <th>
                                姓名
                            </th>
                            <th>
                                性别
                            </th>
                            <th>
                                学位
                            </th>
                            <th>
                                级别
                            </th>
                            <th>
                                积分
                            </th>
                            <th>
                                手机
                            </th>
                            <th>
                                Email
                            </th>
                            <th>
                                归属用户
                            </th>
                            <th>
                                <input type="checkbox" class="checkboxCtrl" group="MemberSelected"  checked=checked/>全选
                            </th>
                        </tr>
                    </thead>
                    @foreach (var item in SelectedMembers)
                    {            
                        <tr id="memberItem" style="@(item.IsNew ? "color:Red" : string.Empty)" onclick="selectedCheckBox(this)">
                            <td>
                                @i
                            </td>
                            <td>
                                @item.RealName
                            </td>
                            <td>
                                @{
                        var modelsex = SexList.SingleOrDefault(c => c.Value == item.Sex);
                        if (modelsex != null)
                        {
                                    @modelsex.Text
                        }
                                }
                            </td>
                            <td>
                                @{
                        var modelDegree = Degree.SingleOrDefault(c => c.Value == item.Degree);
                        if (modelDegree != null)
                        {
                                    @modelDegree.Text
                        }   
                                }
                            </td>
                            <td>
                                @{
                        var modelGrade = MemberGrade.SingleOrDefault(c => c.Value == item.Grade);
                        if (modelGrade != null)
                        { 
                                    @modelGrade.Text;
                        }
                                }
                            </td>
                            <td>
                                @item.Charge
                            </td>
                            <td>
                                @if (item.NoSMS)
                                {
                                    @item.Tel
                                }
                                else
                                { 
                                    <span style="font-weight: bold">不接收信息</span>
                                }
                            </td>
                            <td>
                                @if (item.NoEmail)
                                {
                                    @item.Email
                                }
                                else
                                { 
                                    <span style="font-weight: bold">不接收邮件</span>
                                }
                            </td>
                            <td>
                                @{
                                var managers = string.Join(" ", item.MemberAssignedManagers.Select(c => c.RealName + c.User));
                                    @managers            
                                }
                            </td>
                            <td>
                                <input  type="checkbox" id="MemberSelected" name="MemberSelected" value="@item.ID"  checked="checked" readonly="readonly"/>
                            </td>
                        </tr>
                                i += 1;
                    }
                </table>                
            </div>
            <div id="SelectingMember">
            @{i = 1;}
                <table class="table" width="100%">
                    <thead>
                        <tr class="header">
                            <th>
                                序号
                            </th>
                            <th>
                                姓名
                            </th>
                            <th>
                                性别
                            </th>
                            <th>
                                学位
                            </th>
                            <th>
                                级别
                            </th>
                            <th>
                                积分
                            </th>
                            <th>
                                手机
                            </th>
                            <th>
                                Email
                            </th>
                            <th>
                                归属用户
                            </th>
                            <th>
                                <input type="checkbox" class="checkboxCtrl" group="MemberSelecting" />全选
                            </th>
                        </tr>
                    </thead>
                    @foreach (var item in SelectingMembers)
                    {            
                        <tr id="memberItem" style="@(item.IsNew ? "color:Red" : string.Empty)" onclick="selectedCheckBox(this)">
                            <td>
                                @i
                            </td>
                            <td>
                                @item.RealName
                            </td>
                            <td>
                                @{
                        var modelsex = SexList.SingleOrDefault(c => c.Value == item.Sex);
                        if (modelsex != null)
                        {
                                    @modelsex.Text
                        }
                                }
                            </td>
                            <td>
                                @{
                        var modelDegree = Degree.SingleOrDefault(c => c.Value == item.Degree);
                        if (modelDegree != null)
                        {
                                    @modelDegree.Text
                        }   
                                }
                            </td>
                            <td>
                                @{
                        var modelGrade = MemberGrade.SingleOrDefault(c => c.Value == item.Grade);
                        if (modelGrade != null)
                        { 
                                    @modelGrade.Text;
                        }
                                }
                            </td>
                            <td>
                                @item.Charge
                            </td>
                            <td>
                                @if (item.NoSMS)
                                {
                                    @item.Tel
                                }
                                else
                                { 
                                    <span style="font-weight: bold">不接收信息</span>
                                }
                            </td>
                            <td>
                                @if (item.NoEmail)
                                {
                                    @item.Email
                                }
                                else
                                { 
                                    <span style="font-weight: bold">不接收邮件</span>
                                }
                            </td>
                            <td>
                                @{
                                var managers = string.Join(" ", item.MemberAssignedManagers.Select(c => c.RealName + c.User));
                                    @managers            
                                }
                            </td>
                            <td>
                                <input  type="checkbox" id="MemberSelecting" name="MemberSelecting" value="@item.ID" readonly="readonly" />
                            </td>
                        </tr>
                                i += 1;
                    }
                </table>
                
            </div>
        </div>
        <div class="tabsFooter">
            <div class="tabsFooterContent">
            </div>
        </div>
    </div>
    <div class="formBar">
                    <ul>
                        <li>
                            <div class="buttonActive">
                                <div class="buttonContent">
                                    <button type="button" onclick="$('#GroupCreateFrom').submit()">
                                        提交</button></div>
                            </div>
                        </li>
                        <li>
                            <div class="button">
                                <div class="buttonContent">
                                    <button type="button" class="close">
                                        取消</button></div>
                            </div>
                        </li>
                    </ul>
                </div>
</div>
